-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2주차 다운 #10
base: main
Are you sure you want to change the base?
2주차 다운 #10
Conversation
죄송합니다.. 담부터 커밋 잘할게요..
양방향 및 단방향 둘다 삭제 가능하게 구현
양방향 및 단방향 둘다 삭제 가능하게 구현
양방향 및 단방향 둘다 삭제 가능하게 구현
} catch (SecurityException | MalformedJwtException | ExpiredJwtException | | ||
UnsupportedJwtException | | ||
IllegalArgumentException e) { | ||
throw e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw error 하나로 추상화하는거 어떤가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵
@Slf4j | ||
@RequiredArgsConstructor | ||
@PropertySource("classpath:application.yml") | ||
public class OAuthService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이부분도 얘기해보면 좋을거같아요
this.expirationPeriod = expirationPeriod; | ||
} | ||
|
||
public static GifticonResponse from(final Gifticon gifticon){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final 붙이는거 좋은거같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니다
/** | ||
* 재고 증가 | ||
*/ | ||
public void addStock(Long quantity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0 방어로직 넣어보는거도 좋을거같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 감사합니다
this.owner = owner; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validCheck private메소드로 뺴는거도 좋을거같아요
throw new IllegalArgumentException("브랜드는 필수 입력 값입니다."); | ||
} | ||
if(gifticonUpdate.getDescription() != null && gifticonUpdate.getDescription().isBlank()){ | ||
throw new IllegalArgumentException("설명은 필수 입력 값입니다."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jakerta에서 Validator있는데 이거 쓰는거도 고려해보세용
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 감사합니다
*/ | ||
public PagingResponse<FundingArticleResponse> getFundingArticlePaging( | ||
PagingRequest pagingRequest) { | ||
return PagingResponse.from(fundingArticleJpaRepository.findAll(pagingRequest.toPageable()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리턴할때 메소드 한방에하는거보다 나눠서 쓰는거는 어떤가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니다
public void deleteGifticon(Long gifticonId){ | ||
//상품이 있는지 확인 | ||
Gifticon findGifticon = gifticonJpaRepository.findById(gifticonId).orElse(null); | ||
if(findGifticon == null){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orElseThrow 쓰면 좋을꺼 같네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!
public class UserGifticonService { | ||
private final UserGifticonJpaRepository userGifticonJpaRepository; | ||
|
||
/** | ||
* 유저기프티콘 전체 조회 | ||
*/ | ||
public List<UserGifticon> findUserGifticonAll() | ||
{ | ||
return userGifticonJpaRepository.findAll(); | ||
} | ||
|
||
/** | ||
* 유저기프티콘 상세 조회 | ||
*/ | ||
public UserGifticon findUserGifticon(Long userGifticonId) | ||
{ | ||
return userGifticonJpaRepository.findById(userGifticonId).orElse(null); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
페이징 처리 해주세요!
public void addStock(Long gifticonId, Long stock){ | ||
Gifticon findGifticon = gifticonJpaRepository.findById(gifticonId).orElse(null); | ||
if(findGifticon == null){ | ||
throw new NotFoundGifticonException("해당 상품이 존재하지 않습니다."); | ||
} | ||
findGifticon.addStock(stock); | ||
} | ||
|
||
/** | ||
* 재고 감소 | ||
*/ | ||
@Transactional | ||
public void removeStock(Long gifticonId, Long stock){ | ||
Gifticon findGifticon = gifticonJpaRepository.findById(gifticonId).orElse(null); | ||
if(findGifticon == null){ | ||
throw new NotFoundGifticonException("해당 상품이 존재하지 않습니다."); | ||
} | ||
findGifticon.removeStock(stock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
재고에 동시성 이슈가 발생할 것 같습니다!
List<Gifticon> gifticons = gifticonIds.stream() | ||
.map(gifticonId -> gifticonJpaRepository.findById(gifticonId).orElseThrow()) | ||
.toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JPA메소드에 findByIdIn 쓰면 한 번에 가져오기 편할 거 같아요
가져오고 나서, 리스트 사이즈가 pk리스트 사이즈랑 같은 지 판별하면 굿
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니다
UserGifticon userGifticon = new UserGifticon(); | ||
userGifticon.buyer = gifticonPurchase.getBuyer(); | ||
userGifticon.owner = gifticonPurchase.getOwner(); | ||
userGifticon.gifticon = gifticonPurchase.getGifticon(); | ||
userGifticon.purchaseDate = gifticonPurchase.getPurchaseDate(); | ||
userGifticon.expirationDate = gifticonPurchase.getExpirationDate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 빌더패턴 사용하면 어떨까요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filter는 configurage가 아닌데 여기 폴더에 있네요
저번주에 저가 지적받은 부분이라 남겨둡ㄴ디ㅏ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
죄송합니다
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
.authorizeHttpRequests(authReq -> authReq | ||
.requestMatchers(HttpMethod.OPTIONS).permitAll() | ||
.requestMatchers("/", "/login", "/oauth2/**", "/refresh","/swagger-ui/**","/api-docs","/v3/api-docs/**").permitAll() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위에 WHITELIST 정의하셨는데 url 목록을 이걸로 대체할 수 있을꺼 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵
죄송합니다..